<?php

namespace app\index\controller;

use think\Controller;
use think\Session;
use think\Db;

class Invite extends Controller
{
    public function read($id){
    	$id = request()->get('id');
        $data = Db::name('jobs')->where('id',$id)->cache(10)->select();
    	$list = Db::name('jobs')->cache(10)->limit(3)->select();
        $this->assign('job',$data[0]);
    	$this->assign('list',$list);
    	return $this->fetch('invite');
    }

    public function sendresume()
    {
    	$proid = request()->post('id');
    	$proname = request()->post('jobname');
    	if(Session::get('UserId')){
    		$userid = Session::get('UserId');
    	}else{
    		return json(['message'=>'请登陆!']);
    	}
    	$data = Db::name('user')->where('id',$userid)->select();
        $param['jobid'] = $proid;
    	$param['personid'] = $userid;
    	$param['email'] = $data[0]['email'];
    	$param['phone'] = $data[0]['phone'];
    	$param['username'] = $data[0]['username'];
    	$param['jobname'] = $proname;
        $resume = model('Invite');
        $data = $resume->addresume($param);
        if($data){
           return json(['message'=>'创建成功']);
        }else{
    	   return json(['message'=>$resume->getError()]);
        }
    }
}
